using System;
using System.Linq.Expressions;
using ECommerce.Web.HtmlHelpers;
using Machine.Specifications;
using Selenium;

namespace ECommerce.IntegrationSpecs.TestHelpers
{
    public class View<T>
    {
        private ISelenium selenium;

        public View(ISelenium selenium)
        {
            this.selenium = selenium;
        }

        public View<T> ShouldDisplayText<TProperty>(Expression<Func<T, TProperty>> propertySelector, string text)
        {
            string outputId = HtmlElementIdentityHelper.IdFor(propertySelector);
                
            this.selenium.GetText(String.Format("id={0}", outputId)).ShouldEqual(text);

            return this;
        }
    }
}